From: Jan Beulich Date: Mon, 19 Jul 2021 10:28:09 +0000 (+0200) Subject: libxl/x86: check return value of SHADOW_OP_SET_ALLOCATION domctl X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~315 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=0be5a00af590c97ea553aadb60f1e0b3af53d8f6;p=xen.git libxl/x86: check return value of SHADOW_OP_SET_ALLOCATION domctl The hypervisor may not have enough memory to satisfy the request. While there, make the unit of the value clear by renaming the local variable. Requested-by: Andrew Cooper Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper Reviewed-by: Anthony PERARD --- diff --git a/tools/libs/light/libxl_x86.c b/tools/libs/light/libxl_x86.c index ac09897a63..18c3c77ccd 100644 --- a/tools/libs/light/libxl_x86.c +++ b/tools/libs/light/libxl_x86.c @@ -529,10 +529,20 @@ int libxl__arch_domain_create(libxl__gc *gc, xc_domain_set_time_offset(ctx->xch, domid, rtc_timeoffset); if (d_config->b_info.type != LIBXL_DOMAIN_TYPE_PV) { - unsigned long shadow = DIV_ROUNDUP(d_config->b_info.shadow_memkb, - 1024); - xc_shadow_control(ctx->xch, domid, XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, - NULL, 0, &shadow, 0, NULL); + unsigned long shadow_mb = DIV_ROUNDUP(d_config->b_info.shadow_memkb, + 1024); + int r = xc_shadow_control(ctx->xch, domid, + XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, + NULL, 0, &shadow_mb, 0, NULL); + + if (r) { + LOGED(ERROR, domid, + "Failed to set %lu MiB %s allocation", + shadow_mb, + libxl_defbool_val(d_config->c_info.hap) ? "HAP" : "shadow"); + ret = ERROR_FAIL; + goto out; + } } if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV &&